package com.lsx143.realtime.util;

import com.lsx143.realtime.common.Constants;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;

/**
 * 对Sink的包装
 */
public class WriteUtil {
    /**
     * 将流的数据写出到ClickHouse
     *
     * @param withDimStream 待写出的流
     * @param table         写入的表名
     * @param clz           POJO
     * @param <T>           POJO的泛型
     */
    public static <T> void writeToClickHouse(SingleOutputStreamOperator<T> withDimStream, String table, Class<T> clz) {
        withDimStream.addSink(
                SinkUtil.getClickHouseSink(
                        Constants.CLICKHOUSE_DATABASE,
                        table,
                        clz
                )
        );
    }
}
